set RECV_LISTEN(INVITE) m_invite

proc m_invite {chid raw parent me} {
	regexp {:([^!]+)!([^@]+)@([^ ]+) INVITE [^ ]+ :([^ ]+)} $raw -> nick user host channel
	
	toplevel .dlg_invite
	wm title .dlg_invite {Invite}
	ttk::frame .dlg_invite.fr
	ttk::label .dlg_invite.fr.caption -text \
		"$nick ($user@$host) [tr {has invited you to}] $channel.\n\n[tr \"Join this channel?\"]"
	
	ttk::button .dlg_invite.fr.yes -text [tr "Yes"] -command "inviteresp yes $channel"
	ttk::button .dlg_invite.fr.no -text [tr "No"] -command "inviteresp no $channel"
	
	grid rowconfigure .dlg_invite.fr 0
	grid columnconfigure .dlg_invite.fr 0
	grid rowconfigure .dlg_invite 0
	grid columnconfigure .dlg_invite 0
	
	grid .dlg_invite.fr		-sticky nsew
	grid .dlg_invite.fr.caption	-sticky nsew	-row 0 -column 0 -columnspan 2
	grid .dlg_invite.fr.yes 	-sticky ew	-row 1 -column 0
	grid .dlg_invite.fr.no  	-sticky ew	-row 1 -column 1
}

proc inviteresp {resp channel} {
	if {$resp == "yes"} {
		chanjoin $channel
	}
	
	destroy .dlg_invite.fr.caption .dlg_invite.fr.yes .dlg_invite.fr.no .dlg_invite.fr .dlg_invite
}
